<template>
  <div class="title" :style="opacity">
    <router-link tag="div" to="/">
      <i class="iconfont icon-fanhui"></i>
    </router-link>
    <h3>知音号</h3>
  </div>
</template>
<script>
export default {
  name: "DetailNavbar",
  data() {
    return {
      opacity: 0
    };
  },
  mounted() {
    window.addEventListener("scroll", this.handleScroll);
  },
  destroyed() {
    window.removeEventListener("scroll", this.handleScroll);
  },
  methods: {
    handleScroll() {
      var top = document.documentElement.scrollTop || document.body.scrollTop;
      var opacity = top / 500;
      if (opacity >= 1) {
        opacity = 1;
      }
      this.opacity = opacity;
    },
    return() {}
  }
};
</script>
<style lang="scss" scoped>
@import "~@/assets/style/global.scss";
.title {
  position: fixed;
  top: 0;
  width: 100%;
  height: 70px;
  background: color(bg);
  line-height: 60px;
  text-align: center;
  padding: 20px;
  box-sizing: border-box;
  height: 100px;
  i {
    font-size: 50px;
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
  }
}
</style>
